var app = getApp();
import {post} from "../request";

function initStudentInfo() {
  return new Promise((resolve, rejects) => {
    post("studentLogin",{
      openId: app.globalData.openId,
      nickName: app.globalData.userInfo?app.globalData.userInfo.nickName:"未授权"
    }).then(data => {
      app.globalData.studentInfo = data.studentInfo
      resolve(data)
    }).catch(err => {
      rejects(err)
    })
  })
}
function initTeacherInfo(loginName, password) {
  console.log("user_openId:"+ app.globalData.openId)
  return new Promise((resolve, rejects) => {
    post("teacherLoginWithCache", {
      loginName: loginName,
      password: password,
      openId: app.globalData.openId==null? "":app.globalData.openId, 
      verifyCode: '111111'
    }).then(data => {
      console.log(data);
      app.globalData.teacherInfo = data;
      resolve(data)
    }).catch( err => {
      rejects(err)
    })
  })
}
module.exports = {
  initStudentInfo,
  initTeacherInfo
}